/*
 * 商家管理
 * */

import request from '@/utils/http'
import { BaseResult, PageResult } from '@/types/axios'
import {
  ShopType,
  ShopGetAllParam,
  ShopSaveParam,
  ShopUpdateParam,
  ShopStartParam,
  ShopGetByIdParam,
  ShopExamineParam,
  ShopCheckType,
  CheckGetAllParam,
  CheckGetByIdParam,
  CheckHandleParam,
  CheckDeleteParam
} from './model/businessModel'

// ===========================商家列表页面api========================

export class BusinessService {
  // 商家管理查询
  static getAll(params: ShopGetAllParam) {
    return request.post<BaseResult<PageResult<ShopType[]>>>({
      url: '/shop/getAll',
      data: params
    })
  }

  // 新建商家
  static save(params: ShopSaveParam) {
    return request.post<BaseResult>({
      url: '/shop/save',
      data: params
    })
  }

  // 修改商家
  static update(params: ShopUpdateParam) {
    return request.post<BaseResult>({
      url: '/shop/update',
      data: params
    })
  }

  // 启停用商家
  static start(params: ShopStartParam) {
    return request.post<BaseResult>({
      url: '/shop/start',
      data: params
    })
  }

  // 商家编辑查询
  static getById(params: ShopGetByIdParam) {
    return request.post<BaseResult<ShopType>>({
      url: '/shop/getById',
      data: params
    })
  }

  // 注销商家数据
  static cleanShop(params: ShopGetByIdParam) {
    return request.post<BaseResult<boolean>>({
      url: '/shop/cleanShop',
      data: params
    })
  }

  // 商家入驻审核
  static examine(params: ShopExamineParam) {
    return request.post<BaseResult>({
      url: '/shop/examine',
      data: params
    })
  }

  // ============================入驻申请页面api=======================
  
  // 入驻申请管理查询
  static checkGetAll(params: CheckGetAllParam) {
    return request.post<BaseResult<PageResult<ShopCheckType[]>>>({
      url: '/check/getAll',
      data: params
    })
  }

  // 查看入驻申请详情
  static checkGetById(params: CheckGetByIdParam) {
    return request.post<BaseResult<ShopCheckType>>({
      url: '/check/getById',
      data: params
    })
  }

  // 处理入驻申请
  static checkHandle(params: CheckHandleParam) {
    return request.post<BaseResult>({
      url: '/check/handle',
      data: params
    })
  }

  // 删除入驻申请
  static checkDelete(params: CheckDeleteParam) {
    return request.post<BaseResult>({
      url: '/check/delete',
      data: params
    })
  }
}
